home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / SYS / s / OrganizeWindows.bed < prev    next >
Text File  |  1996-09-26  |  3KB  |  166 lines

  1. /*
  2. ** $VER: OrganizeWindows.bed 1.0 (02.01.96)
  3. **
  4. ** Organizes all the windows on the screen as follows:
  5. **
  6. ** STACK
  7. ** Puts the windows in horizontal slices, stacked vertically on the
  8. ** screen
  9. **
  10. ** CASCADE
  11. ** Puts the windows in a cascade, one top of the other. All title bars
  12. ** then become visible.
  13. **
  14. ** TILE
  15. ** Puts all windows in a 2D tile pattern.
  16. **
  17. ** ICONIFY
  18. ** Iconifies all windows, and aligns them on the left side of the screen.
  19. */
  20.  
  21.  
  22. OPTIONS RESULTS
  23. OPTIONS FAILAT 11
  24. PARSE ARG style
  25.  
  26. IF style ~= "" THEN DO
  27.     style = UPPER(style)
  28.  
  29.     GetScreenInfo
  30.     PARSE VAR RESULT . . screenwidth screenheight . . . '"'screenname'"'
  31.  
  32.     GetDocuments
  33.     docs = RESULT
  34.  
  35.     GetPort
  36.     originalport = RESULT
  37.  
  38.     numicons = 0
  39.     iconheight = 0
  40.     n=0
  41.  
  42.     DO WHILE docs ~= ""
  43.         PARSE VAR docs '"'names.n'"' ports.n docs
  44.         ADDRESS VALUE ports.n
  45.  
  46.         icons.n = FALSE
  47.  
  48.         GetWindowInfo
  49.         IF WORD(RESULT,1) = "ON" THEN DO
  50.             icons.n = TRUE;
  51.             numicons = numicons + 1
  52.             iconheight = WORD(RESULT,5)
  53.         END
  54.  
  55.         n = n+1
  56.     END
  57.  
  58.     availheight = (screenheight - (numicons * iconheight))
  59.     numfull = n - numicons
  60.  
  61.     IF numfull = 0 THEN DO
  62.         style = 'ICONIFY'
  63.     END
  64.  
  65.     IF style = 'STACK' THEN DO
  66.         h = availheight % numfull
  67.         w = 0
  68.         y=0
  69.  
  70.         DO i=0 TO n-1
  71.             IF icons.i = FALSE THEN DO
  72.                 w = w + 1
  73.                 IF (w = numfull) THEN DO
  74.                     h = h + (availheight // numfull)
  75.                 END
  76.  
  77.                 ADDRESS VALUE ports.i
  78.                 MoveSizeWindow 0 y screenwidth h
  79.                 Window2Front
  80.                 y = y + h
  81.             END
  82.         END
  83.     END
  84.  
  85.     IF style = 'CASCADE' THEN DO
  86.         h = availheight
  87.         y = 0
  88.  
  89.         IF iconheight = 0 THEN iconheight = 15
  90.  
  91.         DO i=0 TO n-1
  92.             ADDRESS VALUE ports.i
  93.             IF icons.i = FALSE THEN DO
  94.                 MoveSizeWindow 0 y screenwidth h
  95.                 Window2Front
  96.                 h = h - iconheight
  97.                 y = y + iconheight
  98.             END
  99.         END
  100.     END
  101.  
  102.     IF style = 'ICONIFY' THEN DO
  103.         y = 0
  104.         DO i=0 TO n-1
  105.             ADDRESS VALUE ports.i
  106.             IconifyWindow ON
  107.             GetWindowInfo
  108.             h = WORD(RESULT,5)
  109.             y = y + h + 1
  110.             MoveSizeWindow 0 y
  111.         END
  112.     END
  113.  
  114.     IF style = 'TILE' THEN DO
  115.         DO i=2 TO 100
  116.             IF i*i > numfull THEN LEAVE
  117.         END
  118.  
  119.         i = i-1
  120.         numw = i
  121.         numh = i
  122.         extras = numfull - (i*i)
  123.  
  124.         IF extras > numh THEN DO
  125.             numh = numh + 1
  126.             extras = extras - numw
  127.         END
  128.  
  129.         extras = - (numh - extras)
  130.  
  131.         win = 0
  132.         wininrow = numw + (extras >= 0)
  133.         wwidth = screenwidth % wininrow
  134.         wheight = availheight % numh
  135.         x = 0
  136.         y = 0
  137.         row = 0
  138.  
  139.         DO i=0 TO n-1
  140.             IF icons.i = FALSE THEN DO
  141.                 win = win + 1
  142.                 row = row + 1
  143.  
  144.                 ADDRESS VALUE ports.i
  145.  
  146.                 IF row // wininrow = 0 THEN DO
  147.                     MoveSizeWindow x y (screenwidth - x) wheight
  148.                     x = 0
  149.                     y = y + wheight
  150.                     extras = extras + 1
  151.                     wininrow = numw + (extras >= 0)
  152.                     wwidth = screenwidth % wininrow
  153.                     row = 0
  154.  
  155.                     IF win + wininrow = numfull THEN wheight = availheight - y
  156.                 END; ELSE DO
  157.                     MoveSizeWindow x y wwidth wheight
  158.                     x = x + wwidth
  159.                 END
  160.  
  161.                 Window2Front
  162.             END
  163.         END
  164.     END
  165. END
  166.